﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SundayWishModel.Entities;
using NHibernate;

namespace SundayWishBLL
{
    public class PublicDishHelper:DishHelper
    {
        public PublicDishHelper()
        {
            this.DishPublic = 1;
        }

        public IList<Dish> GetDish()
        {
            ISession Session = NHibernateHelper.GetSession();
            return Session.CreateQuery("from Dish where DishPublic = 1").List<Dish>();
        }

        public bool SetPublicDish(string DishId)
        {
            ISession Session = NHibernateHelper.GetSession();
            Dish dish = Session.Get<Dish>(DishId);
            dish.UserId = -1;
            dish.DishPublic = 1;
            Session.Save(dish);
            Session.Flush();
            return true;
        }
    }
}
